<template>
    <div class="newsinfo-container">
        <h3 class="title">
            {{newsInfo.title}}
        </h3>
        <p class="subtitle">
            <span>发布时间:{{newsInfo.add_time | dateFormat}}</span>
            <span>点击{{newsInfo.click}}次</span>
        </p>
        <hr>
        <div v-html="newsInfo.content"></div>

        <!-- 引入评论组建 -->
        <comment :id="this.id">
            
        </comment>
    </div>
</template>

<script>
//引入评论子组件
import comment from '../subcomment/Comment.vue'
export default {
  data() {
    return {
        newsInfo : [],
        // 获取 地址栏 中的id
        id : this.$route.params.id
    };
  },
  created(){
      this.getNewsInfo()
  },
  methods: {
    getNewsInfo() {
      this.$http.get('api/getnew/' + this.id).then(result => {
          if(result.body.status === 0){
              //成功
            this.newsInfo = result.body.message[0]
          }else{

          }
      })
    }
  },
  //名字，放入到模板中渲染的
   components:{
      comment
  }
};
</script>

<style lang="scss">
.newsinfo-container {
  padding: 0 4px;
  .title {
    font-size: 16px;
    text-align: center;
    margin: 15px 0;
    color: red;
  }
  .subtitle {
    font-size: 13px;
    color: #226aff;
    display: flex;
    justify-content: space-between;
  }
}
</style>
